package stack;

import linearList.LinkedList;

/**
 * 链表实现栈操作，入栈、出栈采用头插入、头删除
 *
 * @param <T>
 */
public class LinkedStack<T> implements Stack<T> {
    private LinkedList<T> list;

    public LinkedStack() {
        this.list = new LinkedList<>();
    }

    public String toString() {
        return "to be done.";
    }

    @Override
    public boolean isEmpty() {
        return false;
    }

    @Override
    public void push(T x) {

    }

    @Override
    public T peek() {
        return null;
    }

    @Override
    public T pop() {
        return null;
    }

    public static void main(String args[]) {
        char[] array = {'a', 'b', 'c', 'd', 'e'};
        LinkedStack<Character> stack2 = new LinkedStack<Character>();

        System.out.print("LinkedStack Push: ");
        for (char ch : array) {
            stack2.push(ch);
            System.out.print(ch + "  ");
        }
        System.out.println();

        System.out.print("LinkedStack Pop: ");
        System.out.println();
        while (!stack2.isEmpty())                  //全部出栈
            System.out.print(stack2.pop().toString() + "  ");
        System.out.println();
    }
}
